package hihocoder;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.IdentityHashMap;
import java.util.Map;
import java.util.Map.Entry;

/**
 * 
 */

/**
 * @author zhongfang
 *
 */
public class LostintheCity {

	public static char[][] rotateSquare(char[][] input) {
		char[][] result=new char[3][3];
		result[2][0]=input[0][0];
		result[1][0]=input[0][1];
		result[0][0]=input[0][2];
		result[2][1]=input[1][0];
		result[1][1]=input[1][1];
		result[0][1]=input[1][2];
		result[2][2]=input[2][0];
		result[1][2]=input[2][1];
		result[0][2]=input[2][2];
		return result;
	}
	
	public static ArrayList<ArrayList<Integer>> inMap(char[][] map,char[][] near) {//可能有多个坐标
		ArrayList<ArrayList<Integer>>  result=new ArrayList<>();
		for (int i = 0; i < map.length-2; i++) {
			for (int j = 0; j < map[1].length-2; j++) {
				//判断[i][j]有没有可能是附近的左上角
				boolean isMatch=true;
				boolean stopTag=false;
				for (int j2 = 0; !stopTag&&j2 < near.length; j2++) {
					for (int k = 0; !stopTag&&k < near[1].length; k++) {
						if(near[j2][k]!=map[i+j2][j+k]){
							isMatch=false;
							stopTag=true;
						}
					}
				}
				if(isMatch){
					ArrayList<Integer> integers=new ArrayList<>();
					integers.add(i+2);
					integers.add(j+2);
					result.add(integers);//中心——+1，从1开始计数——+1
				}
			}
		}
		return result;
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		int N=scanner.nextInt();
		int M=scanner.nextInt();
		scanner.nextLine();
		char[][] map=new char[N][M];
		char[][] near=new char[3][3];
		for (int i = 0; i < N; i++) {
			String string=scanner.nextLine();
			for (int j = 0; j < M; j++) {
				map[i][j]=string.charAt(j);
			}
		}
		//读入附近景点
		for (int i = 0; i < 3; i++) {
			String string=scanner.nextLine();
			for (int j = 0; j < 3; j++) {
				near[i][j]=string.charAt(j);
			}
		}
		TreeMap<Integer, TreeSet<Integer>> results=new TreeMap<>();
		for (int i = 0; i < 4; i++) {
			ArrayList<ArrayList<Integer>> res=inMap(map, near);
			for (ArrayList<Integer> entry :res){
				if(results.containsKey(entry.get(0))){
					results.get(entry.get(0)).add(entry.get(1));
				}else {
					TreeSet<Integer> arrayList=new TreeSet<Integer>();
					arrayList.add(entry.get(1));
					results.put(entry.get(0), arrayList);
				}
			}
			//旋转near矩阵
			near=rotateSquare(near);
		}
		for (Entry<Integer, TreeSet<Integer>> entry : results.entrySet()) {
			int x=entry.getKey();
			for (int c : entry.getValue()) {
				System.out.println(x+" "+c);
			}
		}
	}
}
